﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReadCookie();
    }

    protected bool ReadCookie()
    {
        try
        {
            if (Request.Cookies["daugia_user"] != null)
            {
                string username = Request.Cookies["daugia_user"]["username"].Trim();
                string userid = Request.Cookies["daugia_user"]["userid"].Trim();
                string mltk = Request.Cookies["daugia_user"]["mltk"].Trim();
                if (username.Length > 0 && userid.Length > 0)
                {
                    lnkUserLogin.Text = username;
                    lnkUserLogin.PostBackUrl = "~/Default" + mltk + ".aspx";
                    panelUserState.Visible = true;
                    return true;
                }
            }
        }
        catch (Exception ex)
        {
            lnkUserLogin.Text = "";
            lbUserID.Text = "";
            panelUserState.Visible = false;
            return false;
        }

        lnkUserLogin.Text = "";
        lbUserID.Text = "";
        panelUserState.Visible = false;
        return false;
    }

    protected void UserLogout(object sender, EventArgs args)
    {
        Response.Cookies["daugia_user"].Expires = DateTime.Now.AddDays(-1);
        lbUserID.Text = "";
        panelUserState.Visible = false;
    }

}
